package com.cike.productmanager;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cike.productmanager.util.DataApplication;

public class AListActivity extends Activity {

	private LinearLayout activitylist;
	private TextView storenameview;
	private TextView actnameview;
	private TextView timelimitview;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.alist);
		
		activitylist=(LinearLayout)findViewById(R.id.activityLinearLayout);
		
		
		//根据数据库中活动量创建列表
		for(int i=0;i<DataApplication.activityList.size();i++){
			
			View v = LayoutInflater.from(this).inflate(R.layout.activityitem,null);
			
            storenameview=(TextView)v.findViewById(R.id.storename);
            actnameview=(TextView)v.findViewById(R.id.activityname);
            timelimitview=(TextView)v.findViewById(R.id.timetext);
            
            String storename = ((com.cike.productmanager.adt.AActivity)DataApplication.activityList.get(i)).getStoreBelong();
            String actname = ((com.cike.productmanager.adt.AActivity)DataApplication.activityList.get(i)).getActivityName();
            String timeLimit = ((com.cike.productmanager.adt.AActivity)DataApplication.activityList.get(i)).getTimeLimit();
            
            storenameview.setText(storename);
            actnameview.setText(actname);
            timelimitview.setText(timeLimit);
            
            final int num = i;
            
            v.setOnClickListener(new OnClickListener() {
				
            	/*在这里加入需要的门店信息传值，intent传值，然后在ReadActContent向下再传到CheckActivity
            	   中从ID获取数据库信息*/
				@Override
				public void onClick(View v) {
					Intent intent = new Intent (AListActivity.this,ReadActContent.class);			
					
					
					
					//传递排序过去
					intent.putExtra("ID", num);
					
					startActivity(intent);
				}
			});
            
            activitylist.addView(v);
		}
		
		
	}
	
	
	
}
